﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Configuration;

namespace Net.Mail
{
    /// <summary>
    /// This class creates a config section for a Pop3 client
    /// </summary>
    public class Pop3ClientSection : ConfigurationSection
    {
        [ConfigurationProperty("HostName", IsRequired = true)]
        public string HostName
        {
            get { return (string)this["HostName"]; }
            set { this["HostName"] = value; }
        }
        [ConfigurationProperty("Port", IsRequired = true)]
        public int Port
        {
            get { return (int)this["Port"]; }
            set { this["Port"] = value; }
        }
        [ConfigurationProperty("UserName", IsRequired = true)]
        public string Username
        {
            get { return (string)this["UserName"]; }
            set { this["UserName"] = value; }
        }
        [ConfigurationProperty("Password", IsRequired = true)]
        public string Password
        {
            get { return (string)this["Password"]; }
            set { this["Password"] = value; }
        }
        [ConfigurationProperty("UseSsl", IsRequired = true)]
        public bool UseSsl
        {
            get { return (bool)this["UseSsl"]; }
            set { this["UseSsl"] = value; }
        }

        public Pop3Client getClient()
        {
            return new Pop3Client(this.HostName, this.Port, this.UseSsl, this.Username, this.Password);
        }
    }
}
